# @Author：cnzdy
# @Email：cn_zdy@126.com
# @Time: 2021/10/9 11:18
# @File: utils.py


class AvgrageMeter(object):
    """AvgrageMeter类保存和更新准确率的结果"""

    def __init__(self):
        self.reset()

    def reset(self):
        self.avg = 0
        self.sum = 0
        self.cnt = 0 # count

    def update(self, val, n=1):
        self.sum += val * n
        self.cnt += n
        self.avg = self.sum / self.cnt